#基于centos7.6系统版本
FROM registry.cn-hangzhou.aliyuncs.com/base-linux/centos7.6:v1
MAINTAINER this is nginx1.8.1 image <boren>
#设置工作目录
WORKDIR /usr/local/nginx
#创建临时目录 && 创建nginx的用户
RUN  mkdir -p /var/lib/nginx/tmp/client_body && useradd -s /sbin/nologin -M nginx
#yum安装相关依赖
RUN  yum -y install gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel openssl openssl-devel perl-devel perl-ExtUtils-Embed autoconf  libxslt-devel libxml2 gd-devel perl-ExtUtils-Embed GeoIP GeoIP-devel GeoIP-data gd-devel
#在线下载nginx安装压缩包，解压后删除该压缩包
RUN wget http://nginx.org/download/nginx-1.20.2.tar.gz && tar -xf nginx-1.20.2.tar.gz  && rm nginx-1.20.2.tar.gz
##编译安装nginx后，删除解压后的文件夹
RUN cd nginx-1.20.2 && ./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module --with-http_v2_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module --with-http_image_filter_module=dynamic --with-http_perl_module && make && make install && cd .. && rm -rf  nginx-1.20.2
#创建nginx的用户
#RUN useradd -s /sbin/nologin -M nginx
# 设置nginx执行路径的环境变量
ENV PATH=/usr/local/nginx/sbin/:$PATH
# 修改index.html内容
RUN sed -i "s/Welcome to nginx!/BY Boren/g" /usr/share/nginx/html/index.html
# 暴露80端口
EXPOSE 80
# 启动nginx
CMD ["nginx", "-g","daemon off;"]

